/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function(prices) {
    let result = 0
    let cur = 0
    let next = 0
    for(let i = 0; i < prices.length - 1; i++) {
      cur = prices[i]
      next = prices[i + 1]

      if (cur < next) {
        result += next - cur
      }
    }

    return result
};